// 测试增强的fallback解析功能
const text = '下午2点半与财务讨论现金流报表表逻辑'

console.log('🧪 测试增强的fallback解析功能')
console.log('📝 测试文本:', text)

// 模拟fallback解析逻辑
const now = new Date()
const currentYear = now.getFullYear()
const currentMonth = now.getMonth() + 1
const currentDay = now.getDate()

const result = {
  title: text,
  dueDate: null,
  priority: 'P2',
  category: 'work',
  tags: [],
  notes: '',
  isRecurring: false,
  recurringType: null,
  recurringPattern: null,
  suggestedSubtasks: []
}

// 测试时间模式匹配
const timePatterns = [
  { pattern: /今天/g, date: `${currentYear}-${currentMonth.toString().padStart(2, '0')}-${currentDay.toString().padStart(2, '0')}` },
  { 
    pattern: /(上午|下午|晚上|早上|中午)\s*\d{1,2}(点|时)\s*(半|\d{1,2}分?)?/g, 
    date: `${currentYear}-${currentMonth.toString().padStart(2, '0')}-${currentDay.toString().padStart(2, '0')}` 
  }
]

console.log('\n🔍 测试时间模式匹配:')
for (const timePattern of timePatterns) {
  const matches = text.match(timePattern.pattern)
  console.log(`模式 ${timePattern.pattern}: ${matches ? `匹配到 "${matches[0]}"` : '未匹配'}`)
  
  if (timePattern.pattern.test(text)) {
    result.dueDate = timePattern.date
    console.log(`✅ 设置日期为: ${timePattern.date}`)
    break
  }
}

// 提取关键词作为标签
const keywords = ['财务', '现金流', '讨论会', '报表', '讨论']
for (const keyword of keywords) {
  if (text.includes(keyword) && !result.tags.includes(keyword)) {
    result.tags.push(keyword)
  }
}

console.log('\n📊 最终解析结果:')
console.log('标题:', result.title)
console.log('日期:', result.dueDate ? `✅ ${result.dueDate}` : '❌ 未解析')
console.log('分类:', result.category)
console.log('标签:', result.tags.join(', ') || '无')

if (result.dueDate) {
  console.log('\n✅ Fallback解析成功 - 正确识别时间并设为今天')
} else {
  console.log('\n❌ Fallback解析失败 - 未能识别时间')
}
